package com.dfd.store.dao.impl;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import com.dfd.store.dao.AdminDao;
import com.dfd.store.domain.Admin;
import com.dfd.store.utils.JDBCUtils;

/**
 * 管理员功能的数据访问层的实现类
 * 
 * @author DFD
 *
 */
public class AdminDaoImpl implements AdminDao {
    private QueryRunner runner = new QueryRunner(JDBCUtils.getDataSource());

    // 管理员登录
    @Override
    public Admin login(Admin admin) throws Exception {
        String sql = "select * from admin where username = ? and password = ?";
        Admin a = runner.query(sql, new BeanHandler<Admin>(Admin.class), admin.getUsername(),
                admin.getPassword());
        return a;
    }

}
